#pragma once

#include <atomic>


#include "utility.h"


class ServiceStatus {
public:
    enum Status {
        Null = 0,
        Initializing = 1,
        Initialized = 2,
        Starting = 3,
        Running = 4,
        Stopping = 5,
        Stopped = 6,
    };

    enum SubStatus {
        kSubStatusNull = 0,
        kStoppingListener = 1,
        kStoppingThreadPool = 2,
    };

    std::string toString() const {
        H_CASE_STRING_BIGIN(status_.load());
        H_CASE_STRING(Null);
        H_CASE_STRING(Initialized);
        H_CASE_STRING(Running);
        H_CASE_STRING(Stopping);
        H_CASE_STRING(Stopped);
        H_CASE_STRING_END();
    }

    bool IsRunning() const {
        return status_.load() == Running;
    }

    bool IsStopped() const {
        return status_.load() == Stopped;
    }

    bool IsStopping() const {
        return status_.load() == Stopping;
    }
    bool IsInitialized() const {
        return status_.load() == Initialized;
    }
protected:
    std::atomic<Status> status_ = { Null };
   // std::atomic<SubStatus> substatus_ = { kSubStatusNull };
};
